package com.lst.tools.basics.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;

import java.util.Map;

/**
 * @author: Frank
 * @date: 2019/09/24 13:51
 * @version: V1.0
 */
public class BeanUtils {
    /**
     * 对象转成map
     *
     * @param obj
     * @return
     */
    public static Map<String, Object> objToMap(Object obj) {
        String json = JSON.toJSONString(obj);
        return JSON.parseObject(json, new TypeReference<Map<String, Object>>() {
        });
    }

    /**
     * 对象转成map
     *
     * @param obj
     * @return
     */
    public static Map<String, String> objToStringMap(Object obj) {
        String json = JSON.toJSONString(obj);
        return JSON.parseObject(json, new TypeReference<Map<String, String>>() {
        });
    }
}
